from alipay import AliPay
import os
from drf_movie_rimi import settings

private_key_path = os.path.join(settings.BASE_DIR, 'keys', 'rsa_private_key.pem')
public_key_path = os.path.join(settings.BASE_DIR, 'keys', 'rsa_private_key.pem')
app_private_key_string = open(private_key_path).read()
alipay_public_key_string = open(public_key_path).read()



alipay = AliPay(
    appid="2016091800541924",
    app_notify_url=None,  # 默认回调url
    app_private_key_string=app_private_key_string,
    alipay_public_key_string=alipay_public_key_string,  # 支付宝的公钥，验证支付宝回传消息使用，不是你自己的公钥,
    sign_type="RSA2", # RSA 或者 RSA2
    debug=True  # 默认False
)

order_string = alipay.api_alipay_trade_page_pay(
    out_trade_no="201613413141112",
    total_amount=1000,
    subject='P1802',
    return_url="https://example.com",
    notify_url="https://example.com/notify" # 可选, 不填则使用默认notify url
)

x = order_string

url = "https://openapi.alipaydev.com/gateway.do?" + x
y =1